// stores/message.js
import { defineStore } from 'pinia'

export const useMessageStore = defineStore('message', {
  state: () => ({
    alert: {
      isActive: false,
      options: {
        title: '',
        text: '',
        color: '',
        width: 500
      }
    },
    confirm: {
      isActive: false,
      options: {
        title: '',
        text: '',
        color: '',
        width: 500,
        cancelText: '取消',
        confirmText: '确定'
      }
    },
    loading: {
      isActive: false,
      options: {
        title: '',
        text: '',
        color: '',
        width: 300,
        indeterminate: true,
        value: 0,
        progressColor: 'primary'
      }
    },
    prompt: {
      isActive: false,
      options: {
        title: '',
        text: '',
        color: '',
        width: 500,
        label: '',
        placeholder: '',
        inputType: 'text',
        cancelText: '取消',
        confirmText: '确定'
      }
    },
    toast: {
      isActive: false,
      options: {
        text: '',
        color: '',
        timeout: 3000,
        position: 'top'
      }
    }
  }),
  
  actions: {
    hide(type) {
      if (this[type]) {
        this[type].isActive = false
      }
    },
    
    show(type, options) {
      if (this[type]) {
        this[type] = {
          isActive: true,
          options: options
        }
      }
    }
  }
})